package DMSXL._2024.DP;

public class minCostClimbingStairs {
    public static void main(String[] args) {
        int[] cost = {1,100,1,1,1,100,1,1,100,1};
        System.out.println(new minCostClimbingStairs().minCostClimbingStairs(cost));
    }
    public int minCostClimbingStairs(int[] cost) {
        //dp数组表示到该位置的最小消费
        int[] dp = new int[cost.length + 2];
        dp[1] = 0;
        dp[2] = 0;
        for (int i = 3; i <= cost.length + 1 ; i++) {
            dp[i] = Math.min(dp[i - 1] + cost[i - 2],dp[i - 2] + cost[i - 3]);
        }
        return dp[cost.length + 1];
    }
}
